package com.allen.mk.admin.controller;


import com.allen.mk.admin.service.SysUserService;
import lombok.extern.slf4j.Slf4j;
import response.Result;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author Allen
 * @since 2024-04-11
 */
@Slf4j
@RestController
@RequestMapping("/sys-user")
public class SysUserController {

    @Resource
    private SysUserService sysUserService;

    @ApiOperation("用户注册接口")
    @PostMapping("/register")
    public Result register(@RequestParam(value = "username")String username,
                           @RequestParam(value = "password")String password){
        return sysUserService.register(username,password);
    }

    @GetMapping("/userProfile")
    @PreAuthorize("hasAuthority('管理员')")
    public String userProfile() {
        return "Welcome to User Profile";
    }

}
